﻿using LDM.Framework.MemoryCache;
using Microsoft.Extensions.DependencyInjection;

namespace LDM.Framework.Caches
{
    public static class MemoryCacheExtensions
    {
        /// <summary>
        /// 使用微软提供的内存缓存
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public static IServiceCollection AddMicrosoftMemoryCache(this IServiceCollection services)
        {
            if (services == null)
                throw new ArgumentNullException(nameof(services));
            services.AddSingleton(typeof(IMemoryCache), typeof(MicrosoftMemoryCache));
            return services;
        }
    }
}
